package com.sgl.config.quarz;

import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Configuration
@EnableScheduling
@Component
public class SchedulerListener {

    @Autowired
    public SchedulerAllJob myScheduler;

    /**
     * 应用运行的时候 启动定时任务
     * @throws SchedulerException
     */
    @PostConstruct
    public void schedule() throws SchedulerException {
        System.out.println("PostConstruct:开始运行...");
        myScheduler.scheduleJobs();

    }


}